<?php
class Abiturient extends AppModel {

	var $name = 'Abiturient';
	var $validate = array(
		'passport_ser' => array('notempty'),
		'passport_num' => array('notempty'),
		'passport_data' => array('notempty'),
		'canceled' => array('numeric')
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $belongsTo = array(
		'Gender' => array(
			'className' => 'Gender',
			'foreignKey' => 'gender_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Citizenship' => array(
			'className' => 'Citizenship',
			'foreignKey' => 'citizenship_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Region' => array(
			'className' => 'Region',
			'foreignKey' => 'region_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Schoolflanguage' => array(
			'className' => 'Schoolflanguage',
			'foreignKey' => 'schoolflanguage_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Educationdoctype' => array(
			'className' => 'Educationdoctype',
			'foreignKey' => 'educationdoctype_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

	var $hasMany = array(
		'Contract' => array(
			'className' => 'Contract',
			'foreignKey' => 'abiturient_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Relative' => array(
			'className' => 'Relative',
			'foreignKey' => 'abiturient_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Result' => array(
			'className' => 'Result',
			'foreignKey' => 'abiturient_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Selectedprofession' => array(
			'className' => 'Selectedprofession',
			'foreignKey' => 'abiturient_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
	'Enrolledstudent' => array(
				'className' => 'Enrolledstudent',
				'foreignKey' => 'abiturient_id',
				'dependent' => false,
				'conditions' => '',
				'fields' => '',
				'order' => '',
				'limit' => '',
				'offset' => '',
				'exclusive' => '',
				'finderQuery' => '',
				'counterQuery' => ''
	),		
	
	'Order' => array(
					'className' => 'Order',
					'foreignKey' => 'abiturient_id',
					'dependent' => false,
					'conditions' => '',
					'fields' => '',
					'order' => '',
					'limit' => '',
					'offset' => '',
					'exclusive' => '',
					'finderQuery' => '',
					'counterQuery' => ''
	),
		
		'Targetingintake' => array(
			'className' => 'Targetingintake',
			'foreignKey' => 'abiturient_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);

	var $hasAndBelongsToMany = array(
		'Prioritet' => array(
			'className' => 'Prioritet',
			'joinTable' => 'abiturients_prioritets',
			'foreignKey' => 'abiturient_id',
			'associationForeignKey' => 'prioritet_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		),
		'Privilege' => array(
			'className' => 'Privilege',
			'joinTable' => 'abiturients_privileges',
			'foreignKey' => 'abiturient_id',
			'associationForeignKey' => 'privilege_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		)		
	);
	// вывод списка абитуриетов для обычного секретаря после сканирования
	function getSimpleConditions () {
		$conditions = array('Abiturient.prepared' => 0, 'Abiturient.approved' => 0, 'Abiturient.enrolled' => 0, 'Abiturient.canceled' => 0);
		return $conditions;
	}
	// вывод для зам председателя после оформления абитуриетов
	function getPreparedConditions() {
		$conditions = array('Abiturient.prepared' => 1, 'Abiturient.approved' => 0, 'Abiturient.enrolled' => 0, 'Abiturient.canceled' => 0);	
		return $conditions;
	}
	// вывод списка абитуриетов для председателя для добавлени в рейтинг
	function getApprovedConditions() {
		$conditions = array('Abiturient.prepared' => 1, 'Abiturient.approved' => 1, 'Abiturient.enrolled' => 0, 'Abiturient.canceled' => 0);	
		return $conditions;	
	}
	// вывод списка абитуриетов для председателя для зачисления
	function getEnrolledConditions() {
		$conditions = array('Abiturient.enrolled' => 1, 'Abiturient.prepared' => 1, 'Abiturient.approved' => 1, 'Abiturient.canceled' => 0);	
		return $conditions;	
	}
	// вывод абитуриетов которые забрали свои документы
	function getCanceledConditions() {
		$conditions = array('Abiturient.canceled' => 1);	
		return $conditions;			
	}
}
?>